package me.tuyou.jvm.book;

public class DeedLock {

	static class Add implements Runnable{
		int a, b;
		public Add(Integer a, Integer b){
			this.a = a;
			this.b = b;
		}
		@Override
		public void run() {
			synchronized (Integer.valueOf(a)) {
				synchronized(Integer.valueOf(b)){
					System.out.print(a + b);
				}
			}
		}
	}
	
	public static void main(String[] args) {
		for(int i = 0; i < 1000; i++){
			new Thread(new Add(1, 2), "C-" + String.valueOf(i)).start();
			new Thread(new Add(2, 1), "C-" + String.valueOf(i + "*")).start();
		}
	}
}
